/**
 * 
 */
package org.coldlife.sim.display;

import java.awt.Toolkit;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;

import org.coldlife.sim.grav.World;

/**
 * @author MYE02035
 *
 */
public class MainWindow extends JFrame 
{
	private static final long serialVersionUID = -4373456604032169553L;
	private WorldDisplayPanel drawPanel;
	
	public MainWindow(World world) 
	{
		drawPanel = new WorldDisplayPanel(world);
		
		this.getContentPane().add(drawPanel);
		this.setLocationByPlatform(true);
		this.setSize(640, 480);
		this.setVisible(true);
		this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		
		Toolkit.getDefaultToolkit().setDynamicLayout(true);		
		
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosed(WindowEvent e) {
				drawPanel.stop();
			}
		});
	}
	
	public void start()
	{
		drawPanel.start();
	}
	
	public void stop()
	{
		drawPanel.stop();
	}
	
	public void setWorld(World world)
	{
		drawPanel.setWorld(world);
	}
}
